package sanrenxing.dayEnd.backRepertoryTotal.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sanrenxing.dayEnd.backRepertoryTotal.domain.SeateMX;
import sanrenxing.dayEnd.backRepertoryTotal.service.SeateMXBiz;
import sanrenxing.dayEnd.backRepertoryTotal.service.TransactionService;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 功能:
 * 编写者：
 * 日期：2021
 * 版本：1.0
 */
@RestController
@RequestMapping("/SeateMX")
public class SeateMXController {
    @Autowired
    private SeateMXBiz seateMXBiz;
    //自动装配  业务处理方法 改
    @Autowired
    private TransactionService transactionService;

    @GetMapping("/seatmx")
    public Map<String, Object> addSeateMX(HttpServletRequest req, int page, int limit) {
        //定义多条件查询对象
        SeateMX seateMX = new SeateMX();
        //接收请求中的交易日期
        String tranDate = req.getParameter("tranDate");
        //判断是否加入
        if (tranDate != null && tranDate.trim().length() != 0) {
            seateMX.setTranDate(tranDate);
        }

        //调用业务层多条件查询方法
        String condition = seateMXBiz.getCount(seateMX);
        //执行多条件查询语句
        List<SeateMX> seateMXS = seateMXBiz.findByPage(limit, page, condition);
        //获取总记录行数
        int totalRows = seateMXBiz.count(condition);

        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        //改 席位信息
        map.put("trading",transactionService.TradingSeatLXF());
        map.put("msg", "");
        map.put("data", seateMXS);
        map.put("count", totalRows);

        return map;
    }



}
